import $ from 'zepto';

import Swiper from 'swiper';

import './lib/animate.min.css';

import './css/index.scss';


$("body").on("load",function(){
  $(".load-mask").css("display","block");
});

$(function(){

  $(".load-mask").css("display","none");

  var swiper = new Swiper('.swiper-container', {
    direction: 'vertical', // 垂直切换选项
    loop: false, // 循环模式选项

    on:{
      init: function(){
        swiperAnimateCache(this); //隐藏动画元素 
        swiperAnimate(this); //初始化完成开始动画
      }, 
      slideChangeTransitionEnd: function(){ 
        swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
        //this.slides.eq(this.activeIndex).find('.ani').removeClass('ani'); 动画只展现一次，去除ani类名
        if(swiper.activeIndex==5){
          $("#next").css("display","none");
        } else {
          $("#next").css("display","block");
        }
      } 
    }
  }) ;

  var audio = $("audio")[0];
  $("#music").on("click", function () {
    $(this).toggleClass("music-off");

    if($("#music").hasClass("music-off")){
      // console.log(audio);
      audio.pause();
    } else {
      audio.play();
    }

  });

  $("#p3-btn1").on("click",function(){
    swiper.slideTo(3, 200,function(){
      swiperAnimate(this);
    });
  });
  
  $("#p3-btn2").on("click",function(){
    swiper.slideTo(4, 400,function(){
      swiperAnimate(this);
    });
  });
  
  $("#p3-btn3").on("click",function(){
    swiper.slideTo(5, 600,function(){
      swiperAnimate(this);
    });
  });
  
  $("#back").on("click",function(){
    swiper.slideTo(2, 600,function(){
      swiperAnimate(this);
    });
  });

});